package com.minimalist.common.feign.client.basic;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.basic.vo.dict.DictCacheVO;
import com.minimalist.common.entity.basic.vo.dict.DictInfoVO;
import com.minimalist.common.entity.basic.vo.dict.DictQueryVO;
import com.minimalist.common.entity.basic.vo.dict.DictVO;
import com.minimalist.common.feign.config.FeignConfig;
import com.minimalist.common.feign.fallback.basic.DictFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 字典管理 Feign 客户端
 *
 * @author minimalist
 */
@FeignClient(name = "minimalist-basic", contextId = "dictFeignClient", path = "/basic/dict", configuration = FeignConfig.class, fallbackFactory = DictFeignClientFallbackFactory.class)
public interface DictFeignClient{

    /**
     * 添加字典
     *
     * @param dictInfoVO 字典信息
     * @return Void
     */
    @PostMapping("/addDict")
    ResponseEntity<Void> addDict(@RequestBody DictInfoVO dictInfoVO);

    /**
     * 删除字典 -> 根据字典ID删除
     *
     * @param dictId 字典ID
     * @return Void
     */
    @DeleteMapping("/deleteDictByDictId")
    ResponseEntity<Void> deleteDictByDictId(@RequestParam("dictId") Long dictId);

    /**
     * 修改字典 -> 根据字典ID修改
     *
     * @param dictInfoVO 字典信息
     * @return Void
     */
    @PutMapping("/updateDictByDictId")
    ResponseEntity<Void> updateDictByDictId(@RequestBody DictInfoVO dictInfoVO);

    /**
     * 查询字典列表(分页)
     *
     * @param queryVO 查询条件
     * @return 字典列表
     */
    @GetMapping("/getPageDictList")
    ResponseEntity<PageResp<DictVO>> getPageDictList(@SpringQueryMap DictQueryVO queryVO);

    /**
     * 根据字典ID查询字典信息
     *
     * @param dictId 字典ID
     * @return 字典信息
     */
    @GetMapping("/getDictByDictId/{dictId}")
    ResponseEntity<DictInfoVO> getDictByDictId(@PathVariable("dictId") Long dictId);

    /**
     * 根据字典类型查询字典数据
     *
     * @param dictType 字典类型
     * @return 字典数据
     */
    @GetMapping("/getDictByDictType/{dictType}")
    ResponseEntity<List<DictCacheVO>> getDictByDictType(@PathVariable("dictType") String dictType);
}